<?php
    
/*  Copyright 2009  Manel Villar  (email : manelvf at gmail dot com)

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
*/
	

/*
Plugin Name: webCountdown
Plugin URI: http://URI_Of_Page_Describing_Plugin_and_Updates
Description: A dynamic embedded countdown for your sidebar.
Version: 1.0
Author: Manel Villar
Author URI: http://URI_Of_The_Plugin_Author
*/



function widget_webCountdown() {
	
	// Pre-2.6 compatibility
	if(!defined('WP_PLUGIN_URL')) {
		if(!defined('WP_CONTENT_URL')) {
			define('WP_CONTENT_URL', get_option('siteurl') . '/wp-content');
		}
		define('WP_PLUGIN_URL', WP_CONTENT_URL . '/plugins');
	}
	if(!defined('WP_PLUGIN_DIR')) {
		if(!defined('WP_CONTENT_DIR')) {
			define('WP_CONTENT_DIR', ABSPATH . 'wp-content');
		}
		define('WP_PLUGIN_DIR', WP_CONTENT_DIR . '/plugins');
	}

	
	// load files
	echo '<link rel="stylesheet" href="'.WP_PLUGIN_URL.'/webcountdown/webCountdown.css" type="text/css" media="screen" />';
	echo "<script src='".WP_PLUGIN_URL."/webcountdown/webCountdown.js'></script>";
	
	
	// draw content
    echo '<div class="countDownFullText" id="countDownFullText">';
	echo 'There are<div class="countDownClockDays" id="countDownClockDays"></div><div>days</div>';
	echo '<div id="countDownClockTime"></div>till 04:38PM<br> of April 3rd, 2014</div><br>';

	echo "<script>
	var c = new webCountdown(new Date(),new Date(2017,4,3,16,38,00),'','Time is Over'); // from today to the future
	c.interval = setInterval(c.actualize,1000);
	</script>";
	
}

	

function widget_webCountdown_init() {
	if(function_exists('register_sidebar_widget')) {
		register_sidebar_widget('webCountdown', 'widget_webCountdown');
	}
//	if(function_exists('register_widget_control')) {
//		register_widget_control(array('Born On This Day', 'widgets'), 'widget_born_on_this_day_control');
//	}



}


function widget_webCountdown_activate() {
	update_option('widget_webCountdown_title', __('Count Down'));
	update_option('widget_webCountdown_alignment', 'left');
}



function widget_webCountdown_deactivate() {
	delete_option('widget_webCountdown_title');
	delete_option('widget_webCountdown_alignment');
}



add_action('plugins_loaded', 'widget_webCountdown_init');
register_activation_hook( __FILE__, 'widget_webCountdown_activate' );
register_deactivation_hook( __FILE__, 'widget_webCountdown_deactivate' );

	
?>